<?php
session_start();
include_once "checkLogin.php";
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link href="css/menu.css" rel="stylesheet" type="text/css"/>
    <script src="js/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script src="js/nav.js" type="text/javascript"></script>
    <link rel="stylesheet" href="layui/css/layui.css">
    <script src="js/TweenMax.min.js"></script>
    <link href="css/word.css" rel="stylesheet" type="text/css"/>
    <title>读者档案管理</title>
    <style>
        #content thead tr{
            background-color:#E2F5F7;
        }
        #content thead th{
            color: black;
            font-weight: bold;
            border-right: 2px solid  white;
            text-align: center;
        }
        #content span a{
            color: skyblue;
            position: relative;
            top: 10px;
            left: 89%;
            font-size: 1.1em;
        }
        table td{
            color: black;
        }
        tbody td a{
            font-size: 1.1em;
            color: skyblue;
            cursor: pointer;
        }
    </style>
</head>
<body>
<canvas id="Mycanvas" style="position: absolute;left: 0%;width: 100%;height: 99%"></canvas>
<div id="main">
    <header>
        <div id="header1">
            <div id="a"></div>
            <img src="img/logo1.png">
            <h2 class="letter-wrap"  data-stagger="-0.015">清华大学图书馆管理系统</h2>
            <span>当前登录用户：<?php echo $_SESSION['admin']?></span>
        </div>
    </header>
    <div class="navmain">
        <div id="time"><span></span></div>
        <ul id="nav_all">
            <li><a href="index.php">首页</a></li>
            <?php
            include_once "conn.php";
            $main = new main();
            $info = $main->checkAdmin($_SESSION['admin']);
            if ($info['system']){
                ?>
                <li><a href="#">系统设置</a>
                    <ul style="display: none;">
                        <li><a href="library.php">图书馆信息</a></li>
                        <li><a href="admin.php">管理员设置</a></li>
                        <li><a href="#">参数设置</a></li>
                        <li><a href="shujia.php">书架设置</a></li>
                    </ul>
                </li>
                <?php
            }
            if ($info['readerset']){
                ?>
                <li><a href="#">读者管理</a>
                    <ul style="display: none;">
                        <li><a href="readertype.php">读者类型管理</a></li>
                        <li><a href="user.php">读者档案管理</a></li>
                    </ul>
                </li>
                <?php
            }
            if ($info['bookset']){
                ?>
                <li><a href="tushudangan.php">图书档案管理</a></li>
                <?php
            }
            if ($info['book']){
                ?>
                <li><a>图书借还</a>
                    <ul style="display: none;">
                        <li><a href="bookjieyue.php">图书借阅</a></li>
                        <li><a href="bookxujie.php">图书续借</a></li>
                        <li><a href="bookback.php">图书归还</a></li>
                    </ul>
                </li>
                <?php
            }
            if ($info['syschaxun']){
                ?>
                <li> <a>系统查询</a>
                    <ul style="display: none;">
                        <li><a href="tushudanganchaxun.php">图书档案查询</a></li>
                        <li><a href="jieyuechaxun.php">图书借阅查询</a></li>
                        <li><a href="jieyue.php">借阅到期提醒</a></li>
                    </ul>
                </li>
                <?php
            }
            ?>
            <li>
                <a href="pw.php">更改口令</a>
            </li>
            <li><a href="zhuxiao.php">注销</a> </li>
        </ul>
    </div>
    <div id="b"></div>
    <div id="c">
        <div id="now">当前位置：读者管理 > 读者档案管理 >>></div>
        <div id="content">
            <span><a href="adduser.php">添加读者信息</a></span>
            <table class="layui-table" lay-even  lay-skin="nob">
            <colgroup>
                <col width="150">
                <col>
            </colgroup>
            <thead>
            <tr>
                <th>条形码</th>
                <th>姓名</th>
                <th>读者类型</th>
                <th>证件类型</th>
                <th>证件号码</th>
                <th>电话</th>
                <th>E-mail</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <?php
            include_once "conn.php";
            $main = new main();
            $result = $main->reader();
            for ($i = 0; $i < count($result); $i++) {
                ?>
                <tr>
                    <td> <?php echo $result[$i]['barcode'] ?></td>
                    <td> <a href="xiugaiuser.php?id=<?php echo $result[$i]['id']?>"><?php echo $result[$i]['name'] ?></a></td>
                    <td> <?php echo $result[$i]['typename'] ?></td>
                    <td> <?php echo $result[$i]['zhenjian'] ?></td>
                    <td> <?php echo $result[$i]['idcard'] ?></td>
                    <td> <?php echo $result[$i]['phone'] ?></td>
                    <td> <?php echo $result[$i]['email'] ?></td>
                    <td style="display: flex;justify-content: space-between"><a href="xiugaiuser.php?id=<?php echo $result[$i]['id']?>"><button class="layui-btn">修改</button></a>  <a rel="<?php echo $result[$i]['id']?>"><button class="layui-btn layui-btn-danger">删除</button></a></td>
                </tr>
                <?php
            }
            ?>
            </tbody>
        </table>
        </div>
    </div>
    <footer>
        <hr id="one">
        <hr id="two">
        CopyRight © 2019 www.cdp.cn.com 清华大学图书馆
    </footer>
</div>
</body>
<script src="layui/layui.js"></script>
<script src="js/logo.js"></script>
<script src="js/bg.js"></script>
<script>
    $(function(){
        $("tbody td a").click(function(){
            let name = $(this);
            let id = name.attr("rel"); //对应id
            if (this.innerText === "删除")
            {
                if(window.confirm("是否删除数据？"))
                {
                    $.ajax({
                        type: "POST",
                        url: "delReader.php",
                        data: {
                            id:id
                        },
                        dataType:'JSON',
                        cache: false, //不缓存此页面
                        success: function (data) {
                            if (data.error===1){
                                window.location.reload();
                            }else{
                                alert('删除失败!')
                            }
                        }
                    })
                }
            }
        })
    })
</script>
</html>


